#大牛测试出品
#qq2574674466
from chapter09.Base.base import  Base
from selenium.webdriver.common.by import By
import  time,os
from chapter09.PageObject import fateadm_api


class LoginPage(Base):
    #用户名
    l_user = "name","username"
    #密码
    l_passwd = "name","password"
    #验证码
    l_validate = "name","validateCode"
    #验证码图片
    l_image = "xpath",'//*[@id="signupForm"]/div[1]/div[2]/a/img'
    #登录按钮
    l_login = "id","btnSubmit"

    # #以下为登录页面的4个元素定位语句。
    # def login_user(self):
    #     return self.findele(By.NAME,"username")
    #
    # def login_password(self):
    #     return self.findele(By.NAME,"password")
    #
    # def login_validateCode(self):
    #     return self.findele(By.NAME,"validateCode")
    #
    # def login_validateImage(self):
    #     return self.findele(By.XPATH,'//*[@id="signupForm"]/div[1]/div[2]/a/img')
    #
    # def login_button(self):
    #     return self.findele(By.ID,"btnSubmit")
    

    #以下为登录系统的函数。

    def login_system(self,username,password):
        self.send(self.l_user,username)
        self.send(self.l_passwd,password)
        self.clickbtn(self.l_login)
    # def login_system(self,username,password):
    #     filename = "capture.png"
    #     if os.path.exists(filename):
    #         os.remove(filename)
    #     self.login_validateImage().screenshot(filename)
    #
    #     self.login_user().clear()
    #     self.login_user().send_keys(username)
    #     time.sleep(2)
    #     self.login_password().clear()
    #     self.login_password().send_keys(password)
    #     time.sleep(2)
    #     verification_code = str(fateadm_api.TestFunc())
    #     self.login_validateCode().send_keys(verification_code)
    #     time.sleep(2)
    #     self.login_button().click()
    #     return self.url()

